import Cookies from 'js-cookie'
const UnameKey = 'USER-NAME'
const TokenKey = 'vue_admin_template_token'
const routerKey = 'routerKey'
/*设置token过期时间*/
export function setCookies(key,value,expiresTime) {
  let seconds;
  if(expiresTime==undefined){
    seconds = 3600;
  }else{
    seconds = expiresTime
  }
  let expires = new Date(new Date() * 1 + seconds * 1000)
  return Cookies.set(key, value, { expires: expires })
}

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}


export function getRouter() {
    return Cookies.get(routerKey)
}

export function setRouter(router) {
    return Cookies.set(routerKey, router)
}
export function getUname() {
  return Cookies.get(UnameKey)
}

export function setUname(uName) {
  return setCookies(UnameKey, uName)
}

export function removeUname() {
  return Cookies.remove(UnameKey)
}